﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.IO;


namespace Zen4SyncOrchestratorHost
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Opens the Orchestrator configuration file after the installation is completed.
        /// The file is open using the default application for .config file on the target machine.
        /// </summary>
        /// <param name="savedState"></param>
        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Commit(IDictionary savedState)
        {
            base.Commit(savedState);

            // The installation directory is added in the Context via CustomActionData.
            // See the "Custom Actions Editor" of the Zen4SyncOrchestratorSetup project.
            string orchestratorInstallDir = Context.Parameters["targetdir"];

            string orchestratorConfigFile = Path.Combine(orchestratorInstallDir, "Zen4SyncOrchestratorHost.exe.config");

            System.Diagnostics.Process.Start(orchestratorConfigFile);
        }
    }
}
